package com.theaf.basemodule.web.controller;

import com.theaf.basemodule.common.api.LogService;
import com.theaf.basemodule.common.condition.LogCondition;
import com.theaf.basemodule.common.dto.log.LogDTO;
import com.theaf.basemodule.common.dto.log.LogHisDTO;
import com.theaf.core.web.ResultHandler;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author:songwenke
 * @Description:日志Controller
 * @Date:create in 16:15 2017/12/25
 * @Modified By:
 **/
@RestController
@RequestMapping(value="/log")
@Api(description="日志controller")
public class LogController {
    @Autowired
    private LogService logService;

    @RequestMapping(value = "/viewHis/{id}",  method = RequestMethod.GET)
    @ApiOperation(value = "数据历史日志",response = LogHisDTO.class)
    @ApiImplicitParam(value = "数据ID" , name = "id" , dataType = "long" , paramType = "path")
    public Map viewHis(@PathVariable Long id){
        return ResultHandler.success(logService.findHisLog(id));
    }

    @RequestMapping(value = "/list",  method = RequestMethod.POST)
    @ApiOperation(value = "查询日志",response = LogDTO.class)
    public Map list(@RequestBody @ApiParam(name="查询条件",value="传入json格式",required=true) LogCondition condition){
        return ResultHandler.success(logService.findByCondition(condition));
    }
}
